﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VideoSource;
using System.Diagnostics;
using System.Collections.ObjectModel;

namespace VideoBrowser
{
    /// <summary>
    /// Interaction logic for SearchResult.xaml
    /// </summary>
    public partial class SearchResult : UserControl
    {
        string _keyword;        

        public SearchResult(TabItem theTabItem,string keyword, VideoDataSource vs)
        {           
            InitializeComponent();

            _keyword = keyword;            

            VideoDataSource vds = vs;

            ObservableCollection<VideoItem> videos = vds.GetVedioItemList(_keyword.Trim());

            if (videos.Count > 0)
            {
                this.VideoList.Visibility = Visibility.Visible;
                this.VideoList.ItemsSource = videos;                
                theTabItem.Header = keyword + "(" + videos.Count.ToString() + ")";
            }
            else
            {
                this.VideoList.Visibility = Visibility.Hidden;
                this.NoRecord.Visibility = Visibility.Visible;
                theTabItem.Header = keyword + "(0)";
            }
        }

        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(e.Uri.AbsoluteUri);
        }       
    }
}
